package com.xx.plugin.es.enc.token;

import org.apache.lucene.analysis.TokenStream;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.AbstractTokenFilterFactory;
import org.elasticsearch.index.analysis.NormalizingTokenFilterFactory;

/**
 * 参考：
 * org.elasticsearch.analysis.common.PatternReplaceCharFilterFactory
 * org.elasticsearch.analysis.common.MappingCharFilterFactory
 */
public class EncCharTokenFilterFactory extends AbstractTokenFilterFactory implements NormalizingTokenFilterFactory {

    private EncTokenNormalizer normalizer = null;

    public EncCharTokenFilterFactory(IndexSettings indexSettings, String name, Settings settings) {
        super(indexSettings, name, settings);
        normalizer = new EncTokenNormalizer();
    }

    public EncCharTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
        super(indexSettings, name, settings);
    }

    @Override
    public TokenStream create(TokenStream tokenStream) {
        return new EncTokenFilter(tokenStream, normalizer);
    }
}
